package ms.server.api.controller;

import lombok.extern.slf4j.Slf4j;
import ms.server.api.annotation.Decrypt;
import ms.server.api.annotation.Encrypt;
import ms.server.api.service.AedApiInfoService;
import ms.server.api.bean.po.AedApiInfo;
import ms.server.api.bean.vo.ResultCode;
import ms.server.api.bean.vo.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author ybc
 * @Date 2021/6/25 14:24
 */
@RestController
@Slf4j
public class TestController {

    private final AedApiInfoService aedApiInfoService;

    @Autowired
    public TestController(AedApiInfoService aedApiInfoService) {
        this.aedApiInfoService = aedApiInfoService;
    }


    @GetMapping("/test")
    public ResultVO<List<AedApiInfo>> test(){
        List<AedApiInfo> list = aedApiInfoService.selectAll();
        return new ResultVO<List<AedApiInfo>>(ResultCode.SUCCESS,list);
    }

    @GetMapping("/add")
    public ResultVO<Integer> add(){
        Integer result = aedApiInfoService.add();
        return new ResultVO<Integer>(ResultCode.SUCCESS,result);
    }

    @GetMapping("/testexp")
    public ResultVO<String> testexp(){
        aedApiInfoService.testexp();
        return new ResultVO<String>(ResultCode.SUCCESS,null);
    }

    @Decrypt
    @Encrypt
    @PostMapping("/test")
    public Object test(@RequestBody String json){
        log.info(json);
        return "hello world";
    }

}
